#include <cstdio>
#include <cstring>
#include <queue>

const int N = 201;
int n, m, s, t;
int e_cnt = 1, heads[N], dis[N], ans, cost, pre[N], last[N], f[N];
bool vis[N];

struct Edge {
  int v, nxt, flow, w;
} e[50000];

inline void add(int u, int v, int c, int w) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, e[e_cnt].flow = c, e[e_cnt].w = w;
}

bool spfa() {
  std::queue<int> q;
  memset(dis, 0x3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  memset(f, 0x3f, sizeof(f));
  q.push(s);
  vis[s] = true, dis[s] = 0, pre[t] = -1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    vis[x] = false;
    for (int i = heads[x], v; i; i = e[i].nxt) {
      if (e[i].flow > 0 && dis[v = e[i].v] > dis[x] + e[i].w) {
        dis[v] = dis[x] + e[i].w;
        pre[v] = x;
        last[v] = i;
        f[v] = std::min(f[x], e[i].flow);
        if (!vis[v]) {
          q.push(v);
          vis[v] = true;
        }
      }
    }
  }
  return pre[t] != -1;
}

void MCMF() {
  while (spfa()) {
    int cur = t;
    ans += f[t];
    cost += f[t] * dis[t];
    while (cur != s) {
      e[last[cur]].flow -= f[t];
      e[last[cur] ^ 1].flow += f[t];
      cur = pre[cur];
    }
  }
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("P2153 [SDOI2009]晨跑.in", "r", stdin);
  freopen("P2153 [SDOI2009]晨跑.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  s = 1 + n, t = n;
  int u, v, c;
  for (int i = 1; i <= n; ++i) {
    add(i, i + n, 1, 0);
    add(i + n, i, 0, 0);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &u, &v, &c);
    add(u + n, v, 1, c);
    add(v, u + n, 0, -c);
  }
  MCMF();
  printf("%d %d", ans, cost);
  return 0;
}
